package com.imooc.bigdata.hos.server.filemgr.service;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.Map;

import com.imooc.bigdata.hos.common.model.HosObject;
import com.imooc.bigdata.hos.common.model.HosObjectSummary;
import com.imooc.bigdata.hos.common.model.ObjectListResult;

/**
 * Created by jixin on 18-3-13.
 */
public interface IHosStoreService {
  /**
   * 删除bucket
   */
  public void deleteBucketStore(String bucket) throws IOException;

  /**
   * 创建bucket
   */
  public void createBucketStore(String bucket) throws IOException;

  /**
   * 通过sqltable完成bucket的sqlid计数器
   * @throws IOException
   */
  public void createSeqTable() throws IOException;

  /**
   * 上传
   */
  public void put(String bucket,
                  String key,
                  ByteBuffer content,
                  long length,
                  String mediaType,
                  Map<String, String> properties) throws Exception;

  /**
   * 获取HosObjectSummary
   */
  public HosObjectSummary getSummary(String bucket, String key) throws IOException;

  /**
   * 获取HosObjectSummary lsit
   */
  public List<HosObjectSummary> list(String bucket, String startKey, String endKey) throws IOException;

  /**
   * 浏览一个目录下的子项
   * @param bucket
   * @param dir
   * @param start 借助start来进行分页
   * @param maxCount 记录的条数
   * @return
   * @throws IOException
   */
  public ObjectListResult listDir(String bucket,
                                  String dir,
                                  String start,
                                  int maxCount) throws IOException;

  /**
   * 根据前缀进行匹配
   */
  public ObjectListResult listByPrefix(String bucket,
                                       String dir,
                                       String keyPrefix,
                                       String start,
                                       int maxCount) throws IOException;

  /**
   * 下载文件
   */
  public HosObject getObject(String bucket, String key) throws IOException;

  /**
   * 删除文件
   */
  public void deleteObject(String bucket, String key) throws Exception;


}
